<?php
	require_once (dirname(__FILE__)."/../config/Config.inc");
	require_once (dirname(__FILE__)."/../config/api.inc");
	
	$parm = requestArrayParm($_REQUEST);
	
	$method = getParam('m','get','gglist');
	
	$result['status'] = '1';
	
	if($method == 'gginfo')
	{
		if(empty($parm['id']))
		{
			$result['status'] = '0';
			$result['msg'] = '缺少参数id';
			echoJSON($result);
			exit;
		}
		
		unset($query);
		$query['id'] = $parm['id'];
		$query['status'] = '2';
		$gonggao = _SqlTool::getInfo('gonggao', $query);
		if(empty($gonggao))
		{
			$result['status'] = '0';
			$result['msg'] = '未查询到公告信息';
			echoJSON($result);
			exit;
		}
		
		unset($temp);
		$temp['id'] = $gonggao['id'];
		$temp['title'] = $gonggao['title'];
		$temp['content'] = $gonggao['content'];
		$temp['fbtime'] = date('Y-m-d',$gonggao['fbtime']);
		$result['info'] = $temp;
	}
	
	if($method == 'gglist')
	{
		unset($wheres,$pages,$sorts,$between,$list);
		$wheres['status'] = '2';
		$wheres['fbtime'] = array('<=',time());
		$sorts['fbtime'] = 'desc';
		$resData = _SqlTool::getList('gonggao', $wheres, $pages, $sorts, $between);
		
		foreach ($resData as $key => $val)
		{
			unset($temp);
			$temp['id'] = $val['id'];
			$temp['title'] = $val['title'];
			$temp['fbtime'] = date('Y-m-d',$val['fbtime']);
			
			$list[] = $temp;
		}
		
		$result['list'] = $list;
	}
	
	echoJSON($result);